﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace IMCOM.Imagiality.ImageProcessing.Canvas2D.AutoContrast
{
    public class SecondPointSelection : Canvas2DAutoContrastState
    {
    
        public SecondPointSelection(AutoContrastImageEventListener controller)
            : base(controller)
        {
        }

        public override void MouseDown(object sender, MouseEventArgs e)
        {
        }

        public override void MouseUp(object sender, MouseEventArgs e)
        {
            SetControllerState(new AutoContrastLineDrawn(controller));
        }

        public override void ImagePainted(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Pen pen = new Pen(Color.Green, 3);
            pen.EndCap = System.Drawing.Drawing2D.LineCap.Custom;
            pen.CustomEndCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);

            g.DrawLine(pen, controller.Calculator.LineStartPoint, controller.Calculator.LineEndPoint);
        }

        public override void MouseMoved(object sender, MouseEventArgs e)
        {
            controller.Calculator.LineEndPoint = new Point(e.X, e.Y);
            controller.RefreshCanvas();
        }
    }
}
